package cate.game.play.part;

import cate.common.annotation.SplitParse;
import cate.common.util.SplitParser;
import cate.game.play.config.PlayCfgArgs;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

import java.util.List;

@NoteClass("怪物实例配置")
public class SideCfg {

	@NoteField("快照id")
	public int msInsId;

	@NoteField(value = "主角名字",detail = "不配置就读快照里的")
	public String name;

	@NoteField("动态英雄配置")
	public List<DynHeroCfg> dynHeroCfg;

	@NoteField("静态英雄配置")
	public List<StaticHeroCfg> staticHeroCfg;

	public SideCfg(String code) {
		parse(code);
	}

	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		msInsId = args.getInt("快照", 1);
		name = args.getString("名字", null);
		dynHeroCfg = SplitParser.parse(DynHeroCfg.class, args.get("阵容"));
		staticHeroCfg = SplitParser.parse(StaticHeroCfg.class, args.get("静态阵容"));
	}


	public static final class DynHeroCfg {
		@SplitParse(order = 0, defaultValue = "1", note = "位置")
		public byte pos;

		@SplitParse(order = 1, defaultValue = "1", note = "英雄id")
		public int heroTid;

		@SplitParse(order = 2, defaultValue = "1", note = "等级")
		public int level;

		@SplitParse(order = 3, defaultValue = "0", note = "皮肤")
		public int skin;
	}

	public static final class StaticHeroCfg {

		@SplitParse(order = 0, defaultValue = "1")
		public byte pos;

		@SplitParse(order = 1, defaultValue = "0",note = "英雄实例id")
		public int insTid;
	}
}
